

package com.maoshi.shop.security.api.service;

import com.maoshi.shop.bean.model.User;
import com.maoshi.shop.security.api.model.MaoshiUser;
import com.maoshi.shop.security.comment.enums.App;
import com.maoshi.shop.security.comment.exception.UsernameNotFoundException;
import com.maoshi.shop.security.comment.model.AppConnect;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
 * 用户详细信息
 *
 * @author
 */
public interface MaoshiUserDetailsService extends UserDetailsService {

	/**
	 * 根据用户名或手机号加载用户信息
	 * @param principal
	 * @param appType
	 * @return
	 */
	MaoshiUser loadUserByMobileOrUserName(String principal, Integer appType, Integer loginType);

	MaoshiUser loadUserByAppConnect(AppConnect appConnect);


	User loadUserByMobileOrUserName(String mobileOrUserName,Integer loginType);

	public MaoshiUser getMaoshiUser(Integer appId, User user, String bizUserId);

	// ------------TODO 删除下面两个方法------------------


	/**
	 * 获取前端登陆的用户信息
	 *
	 * @param app 所登陆的应用
	 * @param bizUserId openId
	 * @return UserDetails
	 * @throws UsernameNotFoundException
	 */
	MaoshiUser loadUserByAppIdAndBizUserId(App app, String bizUserId);

	/**
	 * 如果必要的话，插入新增用户
	 * @param appConnect
	 */
	void insertUserIfNecessary(AppConnect appConnect);
}
